﻿using System;
using System.Web.UI;

namespace EmptyWallGallery.FrontEnd.inside.Editor.Categories
{
    public partial class Default : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            switch (Request.QueryString["action"])
            {
                case "Delete":
                    DeleteCat();
                    break;
                case "Edit":
                    {
                        var control = Page.LoadControl("~/Controls/ProductCategoryEdit.ascx");
                        pnlControl.Controls.Add(control);
                    }
                    break;
                default:
                    {
                        var control = Page.LoadControl("~/Controls/ProductCategory.ascx");
                        pnlControl.Controls.Add(control);
                    }
                    break;
            }
        }

        public void DeleteCat()
        {
            if (Request.QueryString["CatID"] != null)
            {
                if (Core.Utilities.Common.Instance.IsNumeric(Request.QueryString["CatID"]))
                    Core.BLL.Categories.Instance.Delete(int.Parse(Request.QueryString["CatID"]), 2);
                    //Cat.WriteCategory(2);
            }
            Response.Redirect("default.aspx");
        }

    }
}